package lab03;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class Test11 {
    public static void main(String[] args) {
        try {
            Class.forName("com.mysql.jdbc.Driver");//注册驱动程序
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        //第二阶段编码，connection,statement,resultset
        Connection connection = null;
        Statement statement = null;

        try {
            connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/java_2017?serverTimezone=UTC",
                    "root","113223" );//三个参数
            statement = connection.createStatement();
            statement.executeUpdate("INSERT INTO t_users(id,username,password,register datetime)" +
                    "VALUES (1,'admin','admin',192312312123）");
            statement.executeUpdate("INSERT INTO t_users(id,username,password,register datetime)" +
                    "VALUES(2,'chen','12345',123123213123)");

        } catch (SQLException e) {
            e.printStackTrace();
        }
        try {
            connection.close();
            statement.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
